/**
 * bind
 * @returns {Function}
 */

Function.prototype.mybind = function () {
  const args = Array.prototype.slice.call(arguments);
  const t = args.shift(); // 删除并返回数组的第一项
  const self = this; // this 指向实例
  return function () {
    return self.apply(t, args);
  };
};

const obj1 = {
  name: "zhangsan",
  age: 20,
};
const obj2 = {
  sayname() {
    console.log("name：", this.name);
  },
};
obj2.sayname.mybind(obj1)();
